package cn.itsource.ymcc.feignclient.factory;

import cn.itsource.ymcc.domain.Login;
import cn.itsource.ymcc.exception.GlobalException;
import cn.itsource.ymcc.feignclient.LoginFeignclient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class LoginFeignclientFallbackFactory implements FallbackFactory<LoginFeignclient> {


    @Override
    public LoginFeignclient create(Throwable throwable) {
        throwable.printStackTrace();

        return new LoginFeignclient() {
            @Override
            public JSONResult saveOrUpdate(Login login) {
                return JSONResult.error(new GlobalException("UAA熔断异常","500"));
            }
        };
    }
}
